﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.TeamTrainViewModel
<link href="@Url.Content("~/Assets/plugins/bootstrap-select/bootstrap-select.min.css")" rel="stylesheet" />
<script src="@Url.Content("~/Assets/plugins/bootstrap-select/bootstrap-select.min.js")"></script>
<link href="@Url.Content("~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css")" rel="stylesheet" />
<link href="@Url.Content("~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css")" rel="stylesheet" />
<script src="@Url.Content("~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js")"></script>
<script src="@Url.Content("~/Assets/plugins/chosen/chosen.jquery.min.js")"></script>
<script src="@Url.Content("~/Assets/js/pages/form-elements.js")"></script>

<style>
    ul > .active {
        font-weight: bold;
    }

    .bootstrap-select {
        width: 100%;
    }

    #table_CreateProject td {
        padding-left: 5px;
        padding-top: 5px;
    }
</style>

<script>
    window.onload = function ()
    {
        $("#datetimepicker").datepicker({
            autoclose: true,
            pickerPosition: "bottom-right"
        });
    };
</script>
<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index", "Home", new { area = "" })"><i class="icon fa fa-home"></i>主页</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>项目模块</a></li>
        </ol>
    </div>
</div>

@{
    if (ViewBag.CreateProjectFlag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;项目添加成功！</strong>
    </div>
    }
    if (ViewBag.CreateProjectFlag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;项目添加失败！</strong> @ViewBag.Info
    </div>
    }
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span class="break"></span>培训列表</h6>
                @{
                    if (CurrentUser.UserID.ToString().Trim().Length!=0)
                    {
                        <div class="panel-actions">
                            <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新增培训&nbsp;&nbsp;</a>
                        </div>
                    }
                }
            </div>
            <div class="panel-body">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a style="color: black" href="#overview" data-toggle="tab">培训</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="overview" class="tab-pane active">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover" style="text-align: center">
                                        <thead>
                                            <tr>
                                                <th style="width: 10%; text-align: center">培训时间</th>
                                                <th style="width: 55%; text-align: center">培训名称</th>
                                                <th style="width: 10%; text-align: center">培训地点</th>
                                                <th style="width: 10%; text-align: center">培训人</th>
                                                <th style="width: 15%; text-align: center">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.TrainData.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.TrainData.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.TrainData.Tables[0].Rows[i];
                                                <tr>
                                                    <td style="color: black">@Convert.ToDateTime(item["TRAIN_TIME"]).ToString("yyyy年MM月dd日")</td>
                                                    <td><a  style="color:cornflowerblue" >@item["TRAIN_TITLE"]</a></td>
                                                    <td style="color: black">@item["TRAIN_ADDRESS"]</td>
                                                    <td style="color: black">@item["TRAIN_PERSONS"]</td>
                                                    <td style="color: black">
                                                        <a>详情</a>
                                                        <a>编辑</a>
                                                        <a>删除</a>
                                                    </td>

                                                </tr>
                                                    }
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndex"], (int)ViewData["pageSize"], (int)ViewData["total"])
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>







<!-- 模态框（Modal） -->

<div class="modal fade" id="CreateTrainModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <script>
        function SubmitCreate()
        {
            var message = "";
            if ($("#tb_TrainTitle").val().length > 30)
            {
                message += " · 培训名称不能超过30字符" + "<br/>";
            }
            if ($("#tb_TrainTitle").val() == "" || $.trim($("#tb_TrainTitle").val()) == "")
            {
                message += " · 培训名称不能为空" + "<br/>";
            }

            if ($("#tb_TrainAddress").val() == "")
            {
                message += " · 培训地点不能为空" + "<br/>";
            }
            if ($("#tb_TrainContent").val() == "")
            {
                message += " · 培训描述不能为空" + "<br/>";
            }
            if ($("#tb_TrainContent").text().length > 200)
            {
                message += " · 培训描述不能超过200个字符" + "<br/>";
            }
            if ($("#select_ProjectLeader").val() == "" || $.trim($("#select_ProjectLeader").val()) == "")
            {
                message += " · 培训人不能为空" + "<br/>";
            }

            if ($("#tb_DeadTime").val() == "" || $.trim($("#tb_DeadTime").val()) == "")
            {
                message += " · 培训时间不能为空" + "<br/>";
            } 
            if ($("#tb_TrainDepartment").val() == "" || $.trim($("#tb_TrainDepartment").val()) == "")
            {
                message += " · 组办单位不能为空" + "<br/>";
            }
            if (message != "")
            {
                $("#lb_CheckCreateTrainMessage").html(message);
                $("#div_CheckCreateTrainMessage").css("display", "block");
                return false;
            }
            else
            {
                $("#lb_CheckCreateTrainMessage").html("");
                $("#div_CheckCreateTrainMessage").css("display", "none");
                $("#frm_CreateTrainModal").submit();
            }
        }
    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
    </style>
    <div class="modal-dialog" style="width: 650px;">
        <div class="modal-content" >
            <form id="frm_CreateTrainModal" action="@Url.Action("CreateProject", "Project", new { area = "DevelopArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">培训
                    </h4>
                    
                </div>
                <div class="alert alert-danger" id="div_CheckCreateTrainMessage" style="display: none">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>
                            <label id="lb_CheckCreateTrainMessage"></label>
                        </strong>
                    </div>
                <div id="div_CreateProject" class="modal-body">
                    
                    <table id="table_CreateProject" style="width: 100%">
                        <tr>
                            <td style="text-align: right">培训名称:</td>
                            <td colspan="3" >
                             
                                <input id="tb_TrainTitle" name="tb_TrainTitle" class="form-control" placeholder="Text" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%;text-align: right">培训地点:</td>
                            <td  style="width: 30%">
                             
                                <input id="tb_TrainAddress" name="tb_TrainAddress" class="form-control" placeholder="Text" type="text" />
                            </td>
                            <td  style="width: 10%;text-align: right">培训人员:</td>
                            <td  style="width: 45%">
                                <select  name="select_ProjectLeader" id="select_ProjectLeader" class="form-control selectpicker" multiple="multiple">
                                    @{
                                        List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["UserList"];
                                        if (userList != null)
                                        {
                                            for (int i = 0; i < userList.Count(); i++)
                                            {
                                                var item = userList[i];
                                                <option value="@item.UserId">@item.UserName</option>
                                            }
                                        }
                                    
                                    }
                                </select>
                            </td>
                        </tr>
                         <tr>
                            <td style="text-align: right">组办单位:</td>
                            <td colspan="3" >
                             
                                <input id="tb_TrainDepartment" name="tb_TrainDepartment" class="form-control" placeholder="Text" type="text" />
                            </td>
                        </tr>
                        
                          <tr>
                            <td  style="text-align: right">培训内容:</td>
                            <td colspan="3" >
                                 <textarea id="tb_TrainContent" name="tb_TrainContent" rows="5" class="form-control" placeholder="Content.."></textarea>
                            </td>
                        </tr>

                        <tr>
                            <td style="text-align: right">培训日期：</td>
                            <td colspan="3">
                                <!-- class="input-append date"-->
                                <div class="input-append date" id="datetimepicker" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                    <input id="tb_DeadTime" name="tb_DeadTime" style="border-color: cornflowerblue" class="form-control" size="16" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                    <span class="add-on"><i class="icon-th"></i></span>
                                </div>
                            </td>
                        </tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="button" onclick="SubmitCreate()" value="新增" class="btn btn-primary" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
    
    
        
</div>